#include <stdio.h>
#include <stdlib.h>
int main(void) {
for (int i = 0; i < 10; i++) {
// Assumindo que RAND_MAX seja pelo menos 2^32-1
//printf("r = %d\n");
// zera bit de sinal, expoente
r = (r & 0x3FFFFFFF) | 0x3F800000; // zera bits de sinal de
//printf("r = %d\n");
// gera numero entre 1 e 2
float f = *((float *)&r);
//printf("f = %f\n", f);
// normaliza entre 0 e 1
f = f - 1;
//printf("f = %f\n", f);
float min = -270.33f;
float max = -47.5f;
float fRand = min + (f * (max - min));
printf("fRand = %f\n", fRand
); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKHZvaWQpIHsKCWZvciAoaW50IGkgPSAwOyBpIDwgMTA7IGkrKykgewoJCWludCByID0gcmFuZCgpOwoJCS8vIEFzc3VtaW5kbyBxdWUgUkFORF9NQVggc2VqYSBwZWxvIG1lbm9zIDJeMzItMQoJCS8vcHJpbnRmKCJyID0gJWRcbiIpOwoKCQkvLyB6ZXJhIGJpdCBkZSBzaW5hbCwgZXhwb2VudGUKCQlyID0gKHIgJiAweDNGRkZGRkZGKSB8IDB4M0Y4MDAwMDA7IC8vIHplcmEgYml0cyBkZSBzaW5hbCBkZSAKCQkvL3ByaW50ZigiciA9ICVkXG4iKTsKCQoJCS8vIGdlcmEgbnVtZXJvIGVudHJlIDEgZSAyCgkJZmxvYXQgZiA9ICooKGZsb2F0ICopJnIpOwoJCS8vcHJpbnRmKCJmID0gJWZcbiIsIGYpOwoJCgkJLy8gbm9ybWFsaXphIGVudHJlIDAgZSAxCgkJZiA9IGYgLSAxOwoJCS8vcHJpbnRmKCJmID0gJWZcbiIsIGYpOwoKCQlmbG9hdCBtaW4gPSAtMjcwLjMzZjsKCQlmbG9hdCBtYXggPSAtNDcuNWY7CgkKCQlmbG9hdCBmUmFuZCA9IG1pbiArIChmICogKG1heCAtIG1pbikpOwoJCXByaW50ZigiZlJhbmQgPSAlZlxuIiwgZlJhbmQpOwoJfQoKCXJldHVybiAwOwp9Cg==